package Rozetka.test;

import Rozetka.Pages.CheckOutPage;
import Rozetka.Pages.HomePage;
import Rozetka.Pages.SearchPage;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.testng.annotations.AfterMethod;

public class OnlineOrder extends TestCondition {

    @DataProvider(name = "OnlineOrder")
    public Object[][] provideData1()
    {
        return new Object[][]         {
                { "GoClever Aries 785", "Kacey", "0637316452", "emailadr7@gmail.com", "1"  },
        };
    }

    @Test(dataProvider = "OnlineOrder")
    public void onlineOrderPositive(String searchQuery, String userName, String phoneNumber, String emailAddress, String amount ) {
        HomePage home = new HomePage(driver);
        home.open();
        SearchPage search = home.searchProduct(searchQuery);
        CheckOutPage checkOutPage = search.makeOrder(amount);
        checkOutPage.fillFields(userName, phoneNumber, emailAddress);
        Assert.assertTrue(checkOutPage.sumbitOrder());
    }


    @AfterMethod
    public void post() {
        HomePage home = new HomePage(driver);
        home.open();
        Assert.assertTrue(home.cleanBasket());
    }

}
